package com.byl.modules.core.controller;

import com.byl.common.modules.controller.BaseController;
import com.byl.common.modules.service.BaseServiceImpl;
import com.byl.modules.core.service.PosterService;
import com.byl.sdk.bean.ResultBean;
import org.apache.http.impl.bootstrap.HttpServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/api/poster")
public class PosterController extends BaseController {


    @Autowired
    PosterService posterService;


    @PostMapping("/list")
    public String query(@RequestBody Map map){
        ResultBean bean= posterService.query(map);
        return success("海报列表",bean);
    }

    @PostMapping("save")
    public String save(@RequestBody Map map){
        int rs=posterService.save(map);
        return rs>0? success("保存成功"):fail("保存失败");

    }

    @PostMapping("/update")
    public String update(@RequestBody Map map, HttpServletRequest request){
        String root= request.getServletContext().getRealPath("/");
        map.put("root",root);
        int rs=posterService.update(map);
        return rs>0? success("修改成功"):fail("修改失败");
    }



   @GetMapping("/delete")
    public String delete(String id) {
        int rs = posterService.delete(id);
        return rs > 0 ? success("删除成功~") : fail("删除失败！");
    }
}
